package brand

import (
	"context"
	"mall/services/product/rpc/internal/mapper"

	"mall/services/product/rpc/internal/svc"
	"mall/services/product/rpc/pb"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteBrandLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDeleteBrandLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteBrandLogic {
	return &DeleteBrandLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DeleteBrandLogic) DeleteBrand(in *pb.DeleteBrandDTO) (*pb.EmptyObj, error) {
	brandMapper := mapper.NewBrandMapper(l.ctx)
	delBrandErr := brandMapper.DeleteCtx(l.svcCtx.DBEngin, in.BrandIdArr)
	if delBrandErr != nil {
		return nil, delBrandErr
	}
	return &pb.EmptyObj{}, nil
}
